# image-to-word/utils/image_handler.py

from PIL import Image

def load_image(image_path):
    """加载图像并返回图像对象"""
    try:
        with Image.open(image_path) as img:
            return img.copy()
    except Exception as e:
        print(f"无法加载图像: {e}")
        return None

def resize_image(image, target_size):
    """调整图像大小以适应目标尺寸"""
    return image.resize(target_size, Image.ANTIALIAS)